<template>
  <view class="container">
    <!-- 订单列表展示 -->
    <view class="order-list">
      <view v-for="(order, index) in orders" :key="index" class="order-item">
        <!-- 支付成功通知 -->
        <view class="top-left">
          <text class="status">支付成功</text>
        </view>

        <!-- 支付时间 -->
        <view class="top-right">
          <text class="time">{{ order.paymentTime }}</text>
        </view>

        <!-- 支付金额 -->
        <view class="bottom-left">
          <text class="amount">支付金额: ￥{{ order.amount }}</text>
        </view>
      </view>
    </view>
  </view>
</template>

<script setup>
import { ref, onMounted } from 'vue';

// 模拟订单数据
const orders = ref([]);

// 随机生成几条订单数据
const generateRandomOrders = () => {
  const randomOrders = [];
  const orderCount = 5; // 生成5条订单数据

  for (let i = 0; i < orderCount; i++) {
    const paymentTime = `2025-03-04 ${String(10 + Math.floor(Math.random() * 10)).padStart(2, '0')}:${String(Math.floor(Math.random() * 60)).padStart(2, '0')}:${String(Math.floor(Math.random() * 60)).padStart(2, '0')}`;
    const amount = (Math.random() * (500 - 50) + 50).toFixed(2); // 随机生成金额，范围在50到500之间

    randomOrders.push({
      paymentTime,
      amount
    });
  }

  return randomOrders;
};

// 页面加载时调用生成数据
onMounted(() => {
  orders.value = generateRandomOrders();
});
</script>

<style scoped>
.container {
  padding: 20px;
  background-color: #f5f5f5;
}

.order-list {
  display: flex;
  flex-direction: column;
  gap: 20px;
  width: 100%;
  max-width: 600px; /* 最大宽度限制 */
  margin: 0 auto;  /* 居中 */
}

.order-item {
  background-color: #fff;
  padding: 15px;
  border-radius: 8px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
  position: relative;
  width: 100%;
  height: 60px;
}

.top-left, .top-right, .bottom-left {
  position: absolute;
}

.top-left {
  top: 10px;
  left: 10px;
  font-size: 14px;
  color: green;
  font-weight: bold;
}

.top-right {
  top: 10px;
  right: 10px;
  font-size: 14px;
  color: #666;
}

.bottom-left {
  bottom: 10px;
  left: 10px;
  font-size: 16px;
  color: #FF4D4F;
}

.status {
  font-size: 14px;
  color: green;
}

.time {
  font-size: 14px;
  color: #666;
}

.amount {
  font-size: 16px;
  color: #FF4D4F;
}
</style>
